<?php
    /*
     * @Author: KingMin 
     * @Date: 2022-3-12 11:42:04
     * @Last Modified by:   KingMin 
     * @Last Modified time: 2022-3-12 11:42:09
     * @The authors website: https://www.kingmin.cn  
    */
    $pagesRoot=substr(str_replace('\\','/',dirname(__FILE__)),0,stripos(str_replace('\\','/',dirname(__FILE__)),'/GatewayWorker'));
    @require_once $pagesRoot.'/include/init.php';
    
    class user{
        public function addOnline($uid="",$dt=[]){
            if(!$uid){
                return false;
            }
            if(!RedisService::op()){
                RedisService::init(3);//tonken  用户信息 uid_*
            }
            $tkFix="webLogin_";
            $bclogintm=30;
            RedisService::setToken($tkFix.$uid);
            $hcuser=RedisService::getUser();
            if($hcuser){
                RedisService::delUser($tkFix.$uid);
                RedisService::setUser($hcuser,$bclogintm);
                return $hcuser;
            }else{
                $user=[
                    "uid"=>$uid,
                    "formType"=>$dt['formType']??"",
                    "token"=>$dt['token']??"",
                    "time"=>date("Y-m-d H:i:s"),
                ];
                RedisService::setUser($user,$bclogintm);
                return $user;
            }
            
        }
        public function userInfo($uid){
            $user=LoginAuth::getLoginDetail($uid);
            return $user;
        }
        public function webBindUser($dt=[]){
            if(!$dt['uid']){
                return false;
            }
            $user=User_Model::webBindUser($dt);
            return $user;
        }
    }
    
    
    
    
?>